/**
 * Created by XiongXuan on 2018/1/10.
 */
var createProjectUrl = "http://127.0.0.1:8085/project";
var updateUserInfoUrl = "http://127.0.0.1:8085/user";

function createProject() {
    var name = document.getElementById("name").value;
    var type = document.getElementById("type").value;
    var contactType = document.getElementById("contactType").value;
    var contact = document.getElementById("contact").value;
    var field = document.getElementById("field").value;
    var intro = document.getElementById("intro").value;

    $.ajax({
        traditional: true,
        type: "PUT", //用POST方式传输
        url: createProjectUrl,
        data: {
            "name":name,
            "type":type,
            "contactType":contactType,
            "contact": contact,
            "field": field,
            "intro": intro
        },
        success: function (result) {
            console.log(result);
            if (result.code == 1) {
                alert(result.msg);
                location.reload();
            }
            else {
                alert(result.msg);
            }
        },
        datatype: "json"
    });
}

function modifyInfo() {
    var nickName = encodeURI(document.getElementById("nickName").value);
    var phoneNumber = document.getElementById("phoneNumber").value;
    var userType  = $('input[name="userType"]:checked').val();
    var schoolName = encodeURI(document.getElementById("schoolName").value);
    var major = encodeURI(document.getElementById("major").value);
    var contactType = document.getElementById("contactType").value;
    var contact = document.getElementById("contact").value;
    var intro = encodeURI(document.getElementById("intro").value);

    $.ajax({
        traditional: true,
        type: "POST", //用POST方式传输
        url: updateUserInfoUrl,
        data: {"phoneNumber":phoneNumber,
            "nickName":nickName,
            "userType":userType,
            "schoolName":schoolName,
            "major":major,
            "contactType": contactType,
            "contact": contact,
            "intro": intro
        },
        success: function (result) {
            console.log(result);
            if (result.code == 1) {
                alert(result.msg);
                location.reload();
            }
            else {
                alert(result.msg);
            }
        },
        datatype: "json"
    });
}


